export function sleep(ms: number) {
  return new Promise((resolve) => setTimeout(resolve, ms));
}
export function randomInteger(min: number, max: number) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}
export const scrapeSleep = async (
  minTime: number = 3000,
  maxTime: number = 10000,
) => {
  const sleepTime = randomInteger(minTime, maxTime);
  await sleep(sleepTime);
};
export function now() {
  let date, month, year;
  const inputDate = new Date();
  date = inputDate.getDate();
  month = inputDate.getMonth() + 1;
  year = inputDate.getFullYear();
  const hours = inputDate.getHours();
  const minutes = inputDate.getMinutes();
  const seconds = inputDate.getSeconds();
  date = date.toString().padStart(2, '0');
  month = month.toString().padStart(2, '0');

  return `${year}-${month}-${date}-${hours}-${minutes}-${seconds}`;
}
export function shuffleArray<T>(array: T[]): T[] {
  const shuffled = [...array];
  for (let i = shuffled.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
  }
  return shuffled;
}
